<template>
    <div class="Detail">
      <detail-banner
        :sightName="sightName"
        :bannerImg="bannerImg"
        :gallaryImgs="gallaryImgs"
      ></detail-banner>
      <detail-header></detail-header>
      <div class="content">
        <detail-list :list="categoryList"></detail-list>
      </div>
    </div>
</template>

<script>
import detailBanner from './components/Banner'
import detailHeader from './components/Header'
import detailList from './components/List'

import axios from 'axios'

export default {
  name: 'Detail',
  data () {
    return {
      sightName: '',
      bannerImg: '',
      gallaryImgs: [],
      categoryList: []
    }
  },
  methods: {
    getDetailInfo () {
      // axios.get(`/api/detail.json?id=${id}`) 或者
      axios.get(`/api/detail.json`, {
        params: {
          id: this.$route.params.id
        }
      })
        .then((res) => {
          res = res.data
          if (res.ret && res.data) {
            const data = res.data
            this.sightName = data.sightName
            this.bannerImg = data.bannerImg
            this.gallaryImgs = data.gallaryImgs
            this.categoryList = data.categoryList
          }
        })
    }
  },
  components: {
    detailBanner,
    detailHeader,
    detailList
  },
  mounted () {
    this.getDetailInfo()
  }
}
</script>

<style scoped lang="stylus">
.content
  height: 20rem
</style>
